package com.bsoft.apiservice.web;

import com.alibaba.fastjson.JSONObject;
import com.bsoft.apiservice.dto.GetSampleRequest;
import com.bsoft.apiservice.dto.SampleReceiveRequest;
import com.bsoft.apiservice.service.ApiService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Tangr
 * @version 1.0
 * @ClassName: ApiController
 * @Description: TODO
 * @date 2023/12/13 10:31
 */
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
@Slf4j
public class FjjController {

    @Resource
    private final ApiService apiService;

    @Resource
    private JdbcTemplate jdbcTemplate;

    @PostMapping("/getSample")
    public JSONObject getSample(@RequestBody GetSampleRequest json) {
        log.info("打印入参:"+json);
        String vbarcode = json.getVbarcode();
        return apiService.getSample(json);


    }

    @PostMapping("/sampleReceive")
    public JSONObject sampleReceive(@RequestBody SampleReceiveRequest json) {
        log.info("打印入参:"+json);
        return apiService.sampleReceive(json);


    }
/*    @PostMapping("/test")
    public String getDateinfo(@RequestBody GetSampleRequest json){
        String doc =  json.getVbarcode();
        String str1 = null;
        String sql =  "select * from l_patientinfo where DOCTADVISENO ='"+doc+"'";
        List<Map<String, Object>> sqd_lists = jdbcTemplate.queryForList(sql);

        for (Map<String, Object> lists:sqd_lists) {
            for (String s:lists.keySet() ) {
                str1 = (String) lists.get("doctadviseno");
            }
        }
        System.out.println("-------------------------------------");
        for (Map<String, Object> lists:sqd_lists) {
            for (Map.Entry<String, Object> s:lists.entrySet()) {
                System.out.println(s.getKey()+"");
                System.out.println(s.getValue());
            }
        }
        return str1;
    }*/
}
